package io.renren.modules.app.controller;

import com.jpay.ext.kit.IpKit;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.PayVO;
import io.renren.modules.app.service.PayService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/pay")
@Api("支付")
public class AppPayController {
    @Autowired
    private PayService payService;

    @PostMapping("/wxPay")
    public R wxPay(HttpServletRequest servletRequest, HttpServletResponse servletResponse, @RequestBody PayVO payVO) {
        IpKit.getRealIp(servletRequest);
        // WxPayApiConfig

        return R.ok().put("result", payService.wxPay(payVO.toDTO()));
    }
}
